import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import VCharts from "v-charts"; // v-charts
import VueClipboard from "vue-clipboard2"; //复制到粘贴板
import ElementUI, { Message } from "element-ui";

import globalComponents from "commons/globalComponents";
import "./globalDefined";
import "./assets/js/directives";
import "./assets/css/index.scss";
import "./assets/font/iconfont/iconfont.css";
import "element-ui/lib/theme-chalk/index.css";
import "ag-grid-community/dist/styles/ag-grid.css";
import "ag-grid-community/dist/styles/ag-theme-balham.css";
import i18n from "./locale/index";

import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(VueQuillEditor)

Vue.config.productionTip = false;

let messageInstance = null;
const overrideMessage = (options) => {
  if (messageInstance) {
    messageInstance.close();
  }
  messageInstance = Message(options);
};
["error", "success", "info", "warning"].forEach((type) => {
  overrideMessage[type] = (options) => {
    if (typeof options === "string") {
      options = {
        message: options,
      };
    }
    options.showClose = true;
    options.type = type;
    return overrideMessage(options);
  };
});
ElementUI.Dialog.props.closeOnClickModal.default = false;
Vue.use(ElementUI, { size: "mini" });
Vue.use(VueClipboard);
Vue.use(VCharts);
Vue.use(globalComponents);
Vue.prototype.$message = overrideMessage;

new Vue({
  i18n,
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");
